#include<bits/stdc++.h>
using namespace std;
#define ll long long

const int  N=1e6;
int a[N],b[N];
int n,m;
int maxn;

bool check(int last){
  int cnt=0;
  for(int i=0;i<n;i++){
    int t=(a[i]-last)/b[i]+1;
    cnt+=t;
  }
  if(cnt<m)return 0;
  else return 1;
}

ll getmaxpoint(int last){
  ll atack=0;
  ll cnt=m;
  for(int i=0;i<n;i++){
    int t=(a[i]-last)/b[i]+1;
    if(a[i]-b[i]*t==0)t--;
    atack+=(a[i]+a[i]-(t-1)*b[i])*t/2;
    cnt-=t;
  }
  atack+=cnt*last;
  return atack;
}

void method1(){
  int last=maxn;
  while(!check(last)&&last>0)last--;
  cout<<getmaxpoint(last)<<endl;
}

void method2(){
  int l=1;
  int r=maxn;
  while(l<r){
    int mid;
    if((l+r)%2==00)
      mid=(l+r)>>1;
    else
      mid=(l+r)/2+1;
    if(check(mid))l=mid;
    else r=mid-1;
  }
}

int main(){
  cin>>n>>m;
  maxn=0;
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
    maxn=max(maxn,a[i]);
  }
  method1();

  return 0;
}